﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SES.CMS.BL;
using SES.CMS.DO;

namespace SES.CMS.AdminCP.PageUC
{
    public partial class ucListProductBrand : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            grvNhanHieuDataSource();
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx?Page=ProductBrand");
        }

        protected void grvNhanHieu_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {

            new cmsNhanHieuBL().Delete(new cmsNhanHieuDO { NhanHieuID = Convert.ToInt32(grvNhanHieu.DataKeys[e.RowIndex].Value) });
            Functions.Alert("Xóa bản ghi thành công", Request.Url.ToString());
        }

        protected void grvNhanHieu_SelectedIndexChanged(object sender, EventArgs e)
        {
            int NhanHieuID = int.Parse(grvNhanHieu.DataKeys[grvNhanHieu.SelectedIndex].Value.ToString());
            Response.Redirect("Default.aspx?Page=ProductBrand&BID="+NhanHieuID);
        }

        protected void grvNhanHieu_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grvNhanHieu.PageIndex = e.NewPageIndex;
            grvNhanHieuDataSource();
        }

        private void grvNhanHieuDataSource()
        {
            grvNhanHieu.DataSource = new cmsNhanHieuBL().SelectAll();
            grvNhanHieu.DataBind();
        }
    }
}